using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Simnova.Collaborate.Presenter;
using Simnova.Collaborate.View;

public partial class FeedbackOverview : System.Web.UI.Page, IFeedbackOverview
{
    private FeedbackOverviewPresenter _feedbackOverviewPresenter;

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        this._feedbackOverviewPresenter = new FeedbackOverviewPresenter(this, int.Parse(Session["UserId"].ToString()));
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    #region IFeedbackOverview Members

    IList IFeedbackOverview.Companies
    {
        set 
        {
            CompaniesDropDownList.DataSource = value;
            CompaniesDropDownList.DataValueField = "CompanyId";
            CompaniesDropDownList.DataTextField = "Name";
            CompaniesDropDownList.DataBind();
        }
    }

    int IFeedbackOverview.SelectedCompanyId
    {
        get 
        {
            int selectedCompanyId;
            int.TryParse(CompaniesDropDownList.SelectedValue, out selectedCompanyId);
            return selectedCompanyId; 
        }
    }

    IList IFeedbackOverview.Products
    {
        set
        {
            ProductsDropDownList.DataSource = value;
            ProductsDropDownList.DataValueField = "ProductId";
            ProductsDropDownList.DataTextField = "Name";
            ProductsDropDownList.DataBind();
        }
    }

    int IFeedbackOverview.SelectedProductId
    {
        get
        {
            int selectedProductId;
            int.TryParse(ProductsDropDownList.SelectedValue, out selectedProductId);
            return selectedProductId; 
        }
    }

    #endregion

    protected void CompaniesDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        this._feedbackOverviewPresenter.LoadProducts();
    }

    protected void ProductsDropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        this._feedbackOverviewPresenter.LoadFeedbackLists();
    }

    #region IFeedbackOverview Members

    IList IFeedbackOverview.TopRatedFeedback
    {
        set 
        {
            TopRatedProductList.DataSource = value;
            TopRatedProductList.DataKeyField = "FeedbackId";
            TopRatedProductList.DataBind();    
        }
    }

    IList IFeedbackOverview.WatchListFeedback
    {
        set
        {
            WatchListDataList.DataSource = value;
            WatchListDataList.DataKeyField = "FeedbackId";
            WatchListDataList.DataBind();
        }
    }

    IList IFeedbackOverview.NewestFeedback
    {
        set
        {
            NewestDataList.DataSource = value;
            NewestDataList.DataKeyField = "FeedbackId";
            NewestDataList.DataBind();
        }
    }

    #endregion
    protected void AddFeedbackButton_Click(object sender, EventArgs e)
    {
        Response.Redirect(@"~\ModifyFeedback.aspx?ProductId=" + ((IFeedbackOverview)this).SelectedProductId.ToString(), true);
    }

    #region IFeedbackOverview Members

    #endregion
}
